﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <script type="text/javascript">
        //不可扩展:不能添加属性 
        var person1 = {
            name:"张三"
        }
        Object.preventExtensions(person1);
        person1.age = 18;
        alert(person1.age);
        alert(Object.isExtensible(person1));

        //密封对象:不能删除属性
        var person2 = {
            name: "张三",
            age : 18
        }
        Object.seal(person2);
        delete person2.age;
        alert(person2.age);
        alert(Object.isSealed(person2));

        //冻结对象：不能修改属性的值 
        var person3 = {
            name: "张三",
            age: 18
        }
        Object.freeze(person3);
        person3.name = "李四";
        alert(person3.name);
        alert(Object.isFrozen(person3));
    </script>
</body>
</html>
